const Router = require('koa-router')

const {
  auth,
  hadAdminPermission
} = require('../middleware/auth.middleware')
const {
  validator
} = require('../middleware/goods.middleware')

const {
  upload,
  create,
  update,
  remove,
  restore,
  findAll
} = require('../controller/goods.controller')

const router = new Router({
  prefix: '/goods'
})

router.post('/upload', auth, hadAdminPermission, upload)
router.post('/create', auth, hadAdminPermission, validator, create)

router.put('/:id', auth, hadAdminPermission, validator, update)

router.post('/:id/off', auth, hadAdminPermission, remove)
router.post('/:id/on', auth, hadAdminPermission, restore)

router.get('/', findAll)

module.exports = router